package com.example.student.controller;

import com.example.student.bean.Emp;
import com.example.student.service.DeptService;
import com.example.student.service.EmpService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class IndexController {
    @Resource
    private EmpService empService;
    @Resource
    private DeptService deptService;
    @RequestMapping("queryAll")
    public Object queryAll(){
        return empService.queryAll();
    }
    @RequestMapping("queryById")
    public Object queryById(String id){
        return empService.queryById(id);
    }
    @RequestMapping("add")
    public Object add(Emp emp){
        int res= empService.addEmp(emp);
        if(res>0){
            return "添加成功!!!";
        }
        return "添加失败!!!";

    }
    @RequestMapping("del")
    public Object del(String id){
        int res=empService.del(id);
        if(res>0){
            return "删除成功!!!";
        }
        return "删除失败!!!";
    }
    @RequestMapping("update")
    public Object update(Emp emp){
        int res= empService.update(emp);
        if(res>0){
            return "修改成功!!!";
        }
        return "修改失败!!!";
    }
    @RequestMapping("queryDept")
    public Object queryDept(){
        return deptService.getAll();
    }

}
